fl.outputPanel.clear();

var dom;
var lib;
var configs = "_CONFIG_";

dom = fl.createDocument();
lib = dom.library;
createSWF("_DIR_");

function createSWF(folderURL){
	var folderContents;
	var fitem, i;
	folderContents = FLfile.listFolder(folderURL + "/","files");
	for(i in folderContents){
		fitem = folderContents[i];
		var inx = fitem.lastIndexOf(".");
		if (inx > 0) {
			var ext = fitem.substr(inx+1).toLowerCase();
			if (ext == "jpg" ||ext == "png" || ext == "gif") {
				dom.importFile(folderURL + "/" + fitem, true);
			}
		}
	}
	
	var lenLib = lib.items.length;
	var item;
	for (i=0; i<lenLib; i++) {
		item = lib.items[i];
		if (item.itemType == "bitmap") {
			item.linkageExportForAS = true;
			item.linkageExportInFirstFrame = true;
			item.linkageBaseClass = "flash.display.BitmapData";
			item.quality = 80;
			var className = item.name.substr(0, item.name.lastIndexOf("."));
			item.linkageClassName = className;
		}
	}
	dom.getTimeline().setSelectedFrames(0,1);
	dom.getTimeline().layers[0].frames[0].actionScript = configs;

	var save_dir = "_SAVE_PATH_";
	fl.saveDocument(dom,save_dir+'.fla');
	dom.exportSWF(save_dir+'.swf');
}




